Public MustInherit Class MatrixBitmapFilter
    Implements IBitmapFilter

    Public Function ApplyFilter(ByVal orig As System.Drawing.Bitmap) As System.Drawing.Bitmap Implements IBitmapFilter.ApplyFilter
        If orig Is Nothing Then Throw New ArgumentNullException

        Dim bitmap As New Bitmap(orig.Width, orig.Height, orig.PixelFormat)
        Dim gr As Graphics = Graphics.FromImage(bitmap)
        Dim ia As New Imaging.ImageAttributes
        ia.SetColorMatrix(GenerateMatrix)
        gr.DrawImage(orig, New Point() {New Point(0, 0), New Point(orig.Width, 0), New Point(0, orig.Height)}, New Rectangle(0, 0, orig.Width, orig.Height), GraphicsUnit.Pixel, ia)
        gr.Dispose()
        Return bitmap
    End Function

    Protected MustOverride Function GenerateMatrix() As Imaging.ColorMatrix

End Class
